package com.wiscamp.ninechapters.problems.infrastructure.po.problems;

import com.wiscamp.ninechapters.ddd.PersistenceObject;
import com.wiscamp.ninechapters.problems.enums.Actions;
import jakarta.persistence.*;
import lombok.Data;

import java.io.Serial;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collection;

/**
 * 题
 */
@Entity
@Data
@Table(name = "problems")
public class ProblemPO implements PersistenceObject {
    @Serial
    private static final long serialVersionUID = -3166405700054112022L;

    /**
     * 题编号
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "problem_id", insertable = false, nullable = false)
    private long problemId = 0;

    /**
     * 题型编号
     */
    @Column(name = "problem_type_id", nullable = false)
    private long problemTypeId = 0;

    /**
     * 题分数
     */
    @Column(name = "problem_score", nullable = false)
    private double problemScore = 0;

    /**
     * 答题时限
     */
    @Column(name = "time_limit", nullable = false)
    private int timeLimit = 0;

    /**
     * 难度
     * 通常为所有Question的平均难度
     */
    @Column(name = "difficulty")
    private int difficulty = 0;

    /**
     * 备注
     */
    @Column(name = "remark")
    private String remark = "";

    /**
     * 是否可用
     */
    @Column(name = "is_active", nullable = false)
    private boolean enabled = true;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    private boolean deleted = false;
    /**
     * 创建用户
     */
    @Column(name = "created_by", nullable = false)
    private long creatorId = 0;

    /**
     * 创建时间
     */
    @Column(name = "created_time", nullable = false)
    private LocalDateTime creationTime;

    /**
     * 编辑用户
     */
    @Column(name = "modified_by")
    private long modifierId = 0;

    /**
     * 编辑时间
     */
    @Column(name = "modified_time")
    private LocalDateTime modificationTime;

    @Transient
    private StemPO stem;

    @Transient
    private Collection<QuestionPO> questions = new ArrayList<>();

    @Transient
    private Actions action = Actions.NONE;

}